home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / science / ack3d.zip / ACK3D.H < prev    next >
Text File  |  1994-01-09  |  9KB  |  279 lines

  1. /* Header file for ACK3D engine interface */
  2. /* Author: Lary Myers */
  3.  
  4. typedef unsigned long    ULONG;
  5. typedef unsigned int    UINT;
  6. typedef unsigned char    UCHAR;
  7.  
  8. /*** Error codes returned from Ack... functions ***/
  9. #define ERR_BADFILE        100
  10. #define ERR_BADCOMMAND        101
  11. #define ERR_BADOBJNUMBER    102
  12. #define ERR_BADSYNTAX        103
  13. #define ERR_LOADINGBITMAP   104
  14. #define ERR_BADDIRECTION    105
  15. #define ERR_BADSTARTX        106
  16. #define ERR_BADSTARTY        107
  17. #define ERR_BADANGLE        108
  18. #define ERR_BADMAPFILE        109
  19. #define ERR_READINGMAP        110
  20. #define ERR_BADPICNAME        111
  21. #define ERR_INVALIDFORM        112
  22. #define ERR_NOPBM        113
  23. #define ERR_BADPICFILE        114
  24. #define ERR_NOMEMORY        115
  25. #define ERR_BADPALFILE        116
  26. #define ERR_BADWINDOWSIZE   117
  27. #define ERR_TOMANYVIEWS        118
  28.  
  29.  
  30. #define INT_ANGLE_1    5
  31. #define INT_ANGLE_2    10
  32. #define INT_ANGLE_4    20
  33. #define INT_ANGLE_6    30
  34. #define INT_ANGLE_30    160
  35. #define INT_ANGLE_45    240
  36. #define INT_ANGLE_90    480
  37. #define INT_ANGLE_135    720
  38. #define INT_ANGLE_180    960
  39. #define INT_ANGLE_225    1200
  40. #define INT_ANGLE_270    1440
  41. #define INT_ANGLE_315    1680
  42. #define INT_ANGLE_360    1920
  43.  
  44. #define GRID_SIZE    64            /* Size of each square */
  45. #define GRID_WIDTH    64            /* Map width */
  46. #define GRID_HEIGHT    64            /* Map height */
  47. #define GRID_MAX    GRID_WIDTH * GRID_HEIGHT
  48. #define GRID_XMAX    GRID_WIDTH * GRID_SIZE
  49. #define GRID_YMAX    GRID_HEIGHT * GRID_SIZE
  50. #define GRID_ARRAY    (GRID_WIDTH+2) * (GRID_HEIGHT+2)
  51.  
  52. #define MAX_WALLBMPS    256            /* Total wall bitmaps allowed */
  53. #define MAX_OBJBMPS    256            /* Total obj bitmaps allowed  */
  54.  
  55. #define MAX_OBJECTS    254            /* Total objects in map */
  56.  
  57. #define MAX_ZONES    8            /* Number of light zones */
  58. #define PAL_SIZE    4096            /* Shading palette ranges */
  59.  
  60. #define MAX_VIEWS    47            /* Total sides to an object */
  61.  
  62. #define DEFAULT_DOOR_SPEED  2
  63. #define MAX_DOORS        10        /* Max opening or closing at one time  */
  64.  
  65. #define DOOR_TYPE_SECRET    0x8000
  66. #define DOOR_LOCKED        0x4000
  67. #define DOOR_TYPE_SLIDE        0x2000
  68. #define DOOR_TYPE_SPLIT        0x1000
  69.  
  70.  
  71. #define DOOR_XCODE        60            /* Map codes for the various doors */
  72. #define DOOR_SIDECODE        61
  73. #define DOOR_YCODE        62
  74.  
  75. #define TYPE_WALL    0
  76. #define TYPE_OBJECT    1
  77.  
  78. #define OF_PASSABLE    0x80            /* Object can be walked thru */
  79. #define OF_ANIMATE    0x40            /* Object bitmaps are animated */
  80.  
  81. #define SHADING_ON    1            /* Used in LightFlag */
  82. #define SHADING_OFF    0
  83.  
  84. #define OBJECT_ACTIVE    1            /* Active and may be moveable */
  85. #define OBJECT_INACTIVE 0            /* Won't be considered moveable */
  86.  
  87.  
  88. #define POV_NOTHING    0            /* Nothing was hit */
  89. #define POV_XWALL    1            /* An X wall was hit */
  90. #define POV_YWALL    2            /* A Y wall was hit */
  91. #define POV_OBJECT    3            /* An object was hit */
  92. #define POV_PLAYER    4            /* The player was hit by object */
  93.  
  94. #define POV_NODOOR    0            /* No door was opened */
  95. #define POV_XDOOR    1            /* An X door was opened */
  96. #define POV_YDOOR    2            /* A Y door was opened */
  97. #define POV_XSECRETDOOR 3            /* An X secret door was opened */
  98. #define POV_YSECRETDOOR 4            /* A Y secret door was opened */
  99.  
  100. #define POV_DOORLOCKED    0x80            /* Bit on if door is locked */
  101.  
  102. typedef struct {
  103.         char    Active;
  104.         UCHAR    bmNum[MAX_VIEWS];
  105.         int        Sides;
  106.         int        Dir;
  107.         UCHAR    Flags;
  108.         UCHAR    CurNum;
  109.         UCHAR    MaxNum;
  110.         char    Speed;
  111.         int        VidRow;
  112.         int        x;
  113.         int        y;
  114.         int        mPos;
  115. } OBJECTS;
  116.  
  117.  
  118. #define DOOR_OPENING    0x80        /* On if door is currently opening */
  119. #define DOOR_CLOSING    0x40        /* On if door is currently closing */
  120.  
  121.  
  122. typedef struct {
  123.         int        mPos;
  124.         int        mPos1;
  125.         UINT    mCode;
  126.         UINT    mCode1;
  127.         UCHAR   ColOffset;
  128.         char    Speed;
  129.         char    Type;
  130.         UCHAR   Flags;
  131. } DOORS;
  132.  
  133. typedef struct {
  134.  
  135.         UINT    far xGrid[GRID_ARRAY];  /* Map for X walls */
  136.         UINT    far yGrid[GRID_ARRAY];  /* Map for Y walls */
  137.  
  138.         UCHAR   far *bMaps[MAX_WALLBMPS]; /* Pointers to wall bitmaps */
  139.         UCHAR   far *oMaps[MAX_OBJBMPS];  /* Pointers to object bitmaps */
  140.  
  141.         UCHAR   far *ScreenBuffer;        /* 64k buffer for screen */
  142.         UCHAR   far *OverlayBuffer;        /* Buffer for compiled overlay */
  143.         UCHAR   far *BkgdBuffer;        /* Buffer for ceiling,floor */
  144.  
  145.         int        xPlayer;        /* X value from 0 to 4095 */
  146.         int        yPlayer;        /* Y value from 0 to 4095 */
  147.         int        PlayerAngle;        /* Angle value from 0 to 1919 */
  148.  
  149.         int        DoorSpeed;        /* Door open/close speed */
  150.         int        NonSecretCode;        /* Wall code for secret door */
  151.  
  152.         UCHAR    TopColor;        /* Base color of ceiling */
  153.         UCHAR    BottomColor;        /* Base color of floor */
  154.  
  155.         UCHAR    LightFlag;        /* 0 = no light shading, 1 = ON */
  156.         UCHAR    PalTable[PAL_SIZE]; /* 16 solid colors, 32 zones */
  157.  
  158.         int        WinStartX;        /* Value of left side of viewport */
  159.         int        WinStartY;        /* Value of top side of viewport */
  160.         int        WinEndX;        /* Value of right side */
  161.         int        WinEndY;        /* Value of bottom side */
  162.         int        CenterRow;        /* Value of (WinEndY-WinStartY)/2 */
  163.         int        WinWidth;        /* Value of WinEndX - WinStartX */
  164.         int        WinHeight;        /* Value of WinEndY - WinStartY */
  165.         UINT    WinLength;        /* Number of dwords in window */
  166.         UINT    WinStartOffset;        /* Value of WinStartY * 320 */
  167.  
  168.         int        MaxObjects;        /* Total objects in map */
  169.         OBJECTS    ObjList[MAX_OBJECTS+1]; /* Current objects in map */
  170.         DOORS    Door[MAX_DOORS];    /* Doors moving at one time */
  171. } ACKENG;
  172.  
  173.  
  174. /******* Prototypes *********/
  175.  
  176. int AckInitialize(ACKENG *ae);
  177. /* Reads trig files, builds wall and object maps, general initialize */
  178. /* Also sets up distance table */
  179.  
  180. int AckReadMapFile(ACKENG *ae,char *MapFileName);
  181. /* Reads map file and setups map grids */
  182.  
  183. int AckLoadBitmap(ACKENG *ae,int BitmapNumber,int BitmapType,char *bmFileName);
  184. /* Loads a bitmap and places in either bMaps or oMaps based on bmType */
  185.  
  186. UCHAR far *AckReadiff(char *FileName);
  187. /* Reads in a .LBM or .BBM file and returns a buffer */
  188.  
  189. int AckLoadAndSetPalette(char *FileName);
  190. /* Reads in a palette file and sets the screen palette */
  191.  
  192. void AckSetPalette(UCHAR far *PalBuffer);
  193. /* Sets a previously loaded palette */
  194.  
  195. int AckLoadWall(ACKENG *ae,int WallNumber,char *bmFileName);
  196. /* Loads a wall bitmap and places it into the wall array */
  197.  
  198. int AckLoadObject(ACKENG *ae,int BmpNumber,char *bmFileName);
  199. /* Loads an object bitmap and places it into the object array */
  200.  
  201. int AckCreateObject(ACKENG *ae,int ObjNumber,int NumBitmaps,UCHAR *bmNums);
  202. /* Fills in ObjList structure with information passed */
  203.  
  204. int AckCreateOverlay(ACKENG *ae, UCHAR far *OverlayScreen);
  205. /* Reads overlay file and compiles into OverlayBuffer */
  206.  
  207. int AckBuildBackground(ACKENG *ae);
  208. /* Builds background buffer from TopColor, BottomColor, and LightFlag */
  209.  
  210. void AckSetVGAmode(void);
  211. /* Places video in standard 320x200 mode 13h */
  212.  
  213. void AckSetTextmode(void);
  214. /* Places video in 80x25 color text mode 3 */
  215.  
  216. void AckFadeIn(int Begin,int Count,UCHAR far *Palette);
  217. /* Fades the screen in from black to the supplied palette */
  218.  
  219. void AckFadeOut(int Begin,int Count);
  220. /* Fades the screen from current palette to black */
  221.  
  222. int AckBuildView(ACKENG *ae);
  223. /* Draws the current view into ScreenBuffer */
  224.  
  225. void AckDrawOverlay(UCHAR far *Screen,UCHAR far *Overlay);
  226. /* Places the overlay graphics on top of the screen */
  227.  
  228. int AckDisplayScreen(ACKENG *ae);
  229. /* Displays the contents of ScreenBuffer and OverlayBuffer if desired */
  230.  
  231. int AckCheckHit(int xPlayer,int yPlayer,int ViewAngle,ACKENG *ae);
  232. /* Checks if a collision occurs */
  233.  
  234. int AckCheckDoorOpen(int xPlayer,int yPlayer,int PlayerAngle,ACKENG *ae);
  235. /* Check if a door in front to open */
  236.  
  237. int AckCheckObjPosn(ACKENG *ae,int xPlayer,int yPlayer,int PlayerAngle);
  238. /* Used by AckMovePOV() and AckMoveObjectPOV() to check collision with objects */
  239.  
  240. void AckCheckObjectMovement(ACKENG *ae);
  241. /* Runs the list of objects to check movement */
  242.  
  243. int AckMovePOV(ACKENG *ae,int Angle,int Amount);
  244. /* Moves the POV by the specified amount at the specified angle */
  245.  
  246. int AckMoveObjectPOV(ACKENG *ae,int ObjIndex,int Angle,int Amount);
  247. /* Moves the object POV by the specified amount at the specified angle */
  248.  
  249. int AckGetObjectHit(void);
  250. /* Returns the object index number of the last object hit */
  251.  
  252. int AckGetWallHit(void);
  253. /* Returns the map location of the last wall hit */
  254.  
  255. int AckDeleteObject(ACKENG *ae,int ObjectIndex);
  256. /* Removes the specified object from the map */
  257.  
  258. void AckReplaceBitmap(UINT far *xGrid,UINT far *yGrid,UCHAR OldBmp,UCHAR NewBmp);
  259. /* Runs through the map and replaces old bitmaps with new bitmaps */
  260.  
  261. void AckOverlayBitmap(UCHAR far *destination,UCHAR far *source);
  262. /* Copies non-transparent colors from source onto destination bitmap */
  263.  
  264. UCHAR far *AckCopyNewBitmap(UCHAR far *OldBitmap);
  265. /* Creates a new bitmap buffer and copies OldBitmap into it */
  266.  
  267. UCHAR far *AckGetBitmapPtr(int BitmapNumber,UCHAR far **Maps);
  268. /* Returns a real memory pointer to the specified bitmap */
  269.  
  270. int AckSetNewBitmapPtr(int BitmapNumber,UCHAR far **Maps,UCHAR far *NewBitmap);
  271. /* Sets a new or changes image into the bitmap array */
  272.  
  273. int AckFreeBitmap(UCHAR far *Bmp);
  274. /* Frees up the memory used by the bitmap */
  275.  
  276. int AckWrapUp(ACKENG *ae);
  277. /* Frees memory buffers */
  278.  
  279.